function checkIDCardNo (id){
    var reg = /^[1-6][0-7][\d]{4}((19[\d]{2})|(20[0-1][\d]))((0[1-9])|(1[0-2]))((0[1-9])|([1-2]\d)|(3[0-1]))[\d]{3}[\dx]$/;
    var isFormatMatch = reg.test(id);
    if (!isFormatMatch) {
        console.log("base format does not match ID Card");
        return false;
    };
    var ids = id.split("");
    var modulus = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    var matchLast = [1,0,"X",9,8,7,6,5,4,3,2]
    var sum = 0;
    for (var i = 0; i < modulus.length; i++) {
        sum += (modulus[i] * ids[i]);
    };

    var checksum = matchLast[sum % 11];
    if (checksum != ids[ids.length-1].toUpperCase()) {
        console.log("error: checknum does not match");
        return false;
    }
    return true;
}
